package net;

import java.io.IOException;
import java.io.InputStream;
import java.net.ServerSocket;
import java.net.Socket;

public class TcpServerDemo01 {
    public static void main(String[] args) {
        try {
            ServerSocket serverSocket = new ServerSocket(6666);

            Socket socket = serverSocket.accept();

            InputStream in = socket.getInputStream();

            byte[] bytes = new byte[1024];
            int length = in.read(bytes);

            System.out.println("客户端发送的数据：" + new String(bytes, 0, length));

            in.close();
            socket.close();
            serverSocket.close();
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }
}
